import pygame

DRAW_VECTORS = False

class ShipHUD():

    def __init__(self):
        self.hide = False

    def draw(self, surface, player):
        #Thrust bar percentages
        main_percent = player.ship.engine.main_level
        side_percent = player.ship.engine.side_level
        
        # Set up thrust bar rects
        main_thrust_rect = pygame.rect.Rect(640-60, 640-100, 20, -80*main_percent)
        side_thrust_rect = pygame.rect.Rect(640-30, 640-100, 20, 80*side_percent)
        
        # Create the thrust bar labels
        main_thrust_font = pygame.font.Font(None, 12)
        main_thrust_label_surf = main_thrust_font.render("Main",True,pygame.Color("green"))
        main_thrust_label_surf_size = main_thrust_font.size("Main")
        main_thrust_label_pos = (640-65-main_thrust_label_surf_size[0],640-105)
        
        # Draw main thrust bar
        pygame.draw.rect(surface, pygame.color.Color(int((255-(255.*abs(main_percent)))), int(255.0*abs(main_percent)),0), main_thrust_rect)
        # And the label
        surface.blit(main_thrust_label_surf, main_thrust_label_pos)
        # Draw side thrust bar
        pygame.draw.rect(surface, pygame.color.Color(int((255-(255.*abs(side_percent)))), int(255.0*abs(side_percent)),0), side_thrust_rect)
        
        
        if DRAW_VECTORS:
            startpos = player.ship.pos.get_screen_coords()
            
            force_vector = player.ship.thrust * 3
            end_force_pos = (startpos[0] + force_vector.x, startpos[1] - force_vector.y)
            
            arrow_vector = player.ship.direction * 15
            
            endpos = (startpos[0] + arrow_vector.x, startpos[1] - arrow_vector.y)
            
            pygame.draw.aaline(surface, pygame.Color("red"),startpos , end_force_pos)
            pygame.draw.circle(surface, pygame.Color("red"), startpos, 2)
            
            pygame.draw.aaline(surface, pygame.Color("yellow"),startpos , endpos)
            pygame.draw.circle(surface, pygame.Color("yellow"), startpos, 2)
        